package com.wyh.utils.sqlUtils.repairstatus;

import com.wyh.entity.Repairstatus;

public class addRepairStatusSqlDynamic {
    public String addDynamic(Repairstatus repairstatus) {
        StringBuilder builder = new StringBuilder();
        StringBuilder parameterPlaceholders = new StringBuilder();
        if (repairstatus.getRemark()!=null){
            if (builder.length() > 0) {
                builder.append(", ");
                parameterPlaceholders.append(", ");
            }
            builder.append("remark ");
            parameterPlaceholders.append("#{remark}");
        }

        StringBuilder sql = new StringBuilder();
        sql.append("INSERT INTO repairstatus ( issue, type, progress, priority, time, repair_user_id_fk, house_id_fk, ");
        sql.append(builder);
        sql.append(") VALUES ( #{issue}, #{type}, #{progress}, #{priority},  #{time}, #{name}, #{address}, ");
        sql.append(parameterPlaceholders);
        sql.append(");");

        System.out.println(sql);
        return sql.toString();
    }
}
